function getCookieVal(offset) 
{
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
	  endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}
//获取Cookies的通用方法
function GetCookie (name) 
{
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) 
	  {
	  var j = i + alen;
	  if (document.cookie.substring(i, j) == arg)
		 return this.getCookieVal (j);
	  i = document.cookie.indexOf(" ", i) + 1;
	  if (i == 0) 
		 break; 
	  }
   return null;
}

//设置Cookies的通用方法 
function SetCookie(name, value) 
{
   var argv = this.SetCookie.arguments;
   var argc = this.SetCookie.arguments.length;
   var expires=new Date(); 
   expires.setTime(expires.getTime()+(3650*24*60*60*1000)); 
   var path = (3 < argc) ? argv[3] : null;
   var domain = (4 < argc) ? argv[4] : null;
   var secure = (5 < argc) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) +
	 ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	 ((path == null) ? "" : ("; path=" + path)) +
	 ((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}

function randomURL(url)
{
	if(url.indexOf("javascript")==-1){
		var Current_Date = new Date();	
		var Current_Year = Current_Date.getYear(); 
		var Current_Month = Current_Date.getMonth(); 
		var Current_Today = Current_Date.getDate();
		var Current_Hours = Current_Date.getHours(); 
		var Current_Minutes = Current_Date.getMinutes();
		var Current_Seconds = Current_Date.getSeconds();	
		var randomStr = Current_Year+""+Current_Month+""+Current_Today+""+Current_Hours+""+Current_Minutes+""+Current_Seconds+Math.random()*20 + 1;
		if(url.indexOf("?")>1 ){
			url += "&commixrandom="+randomStr;
		}else{
			url += "?commixrandom="+randomStr;
		}
	}
	return url;
}

var GFRAME = new gooframe();
function gooframe()
{
	this.overCust = new Object();
	this.overCust.custid = 0;	
	this.overCust.custname = "";
}

gooframe.prototype.pageMenuShow = function(code,url,obj)
{
	var app = function()
	{
		GFRAME.restFrame();
		if(pageShowFrame_Map.GFRAME){
			pageShowFrame_Map.GFRAME.reloadDataTimeout = false;//关闭监控地图实时刷新
		}
		var bt = document.getElementsByName("flag");
		var fm = document.getElementsByTagName("iframe");
		
		for(var i=0;i<bt.length;i++){
			if(fm[i].parentNode.className=="pageShowCanvas"){
				fm[i].parentNode.style.display = "none";
			}
			bt[i].parentNode.parentNode.className='';
		}
		for(var i=0;i<fm.length;i++){
			if(fm[i].parentNode.className=="pageShowCanvas"){
				fm[i].parentNode.style.display = "none";
			}
		}
		obj.parentNode.parentNode.className='current';
		var canvasID = "pageShowCanvas_"+code;
		var frameID = "pageShowFrame_"+code;
		var _div_obj = document.getElementById(canvasID);
		var _frame_obj = document.getElementById(frameID);
		_div_obj.style.display = "block";	
		if(code=="Card"){
			var dPage = top.GetCookie("dPage");
			if(dPage==""||dPage==null)dPage=20;
			url = url+"&dpage="+dPage;
		}
		if(_frame_obj.getAttribute("src").indexOf('null.html')>-1 && url !=null){
			_frame_obj.setAttribute("src",randomURL(url));
		};
		if(code=="Sales"&&rootLoadSalePageTimer!=null){window.clearTimeout(rootLoadSalePageTimer);}
		if(code=="Map"&&pageShowFrame_Map.GFRAME){pageShowFrame_Map.GFRAME.reloadDataTimeout = true;}//开启监控地图的数据实时刷新
	
	};
	var check = function()
	{
		if(login_msg)
		{
			app();
		}
		else
		{
			//在请求中断时候继续发送请求login_msg
			loadMessageCallBackJs();
			setTimeout(check,1000);
		}
	};
	if(code=="Sales"){check();}else{app();};
}

gooframe.prototype.selectCust = function(cust)
{
	this.overCust.custid = cust.custid;
	this.overCust.custname = cust.custname;
}
gooframe.prototype.restFrame = function()
{
	var w = document.documentElement.clientWidth;
	var h = document.documentElement.clientHeight;
	if(w<400){w=400;}
	if(h<300){h=300;}
	var fm = document.getElementsByTagName("iframe");
	for(var i=0;i<fm.length;i++){
		if(fm[i].parentNode.className=="pageShowCanvas"){
			fm[i].parentNode.style.width = (w-12)+"px";
			fm[i].parentNode.style.height = (h-108)+"px";
			fm[i].style.height = (h-108)+"px";
			fm[i].style.overflow = "auto";
		}
	}
}
